package csel.view;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionListener;

import csel.model.*;
import csel.model.items.*;
import csel.model.skills.Skill;
import csel.model.entity.Character;
import csel.view.status.BottomMenu;
import csel.view.status.IDPanel;
import csel.view.status.NumberBar;

public class StatusViewport extends Viewport implements Observer
{

	//the viewport's window
	private JPanel myPanel;

	//component panels
	private NumberBar myNumBar;
	private BottomMenu myBottomMenu;
	private IDPanel myIDPanel;
	
	private Model myModel;

	public StatusViewport(Model m, ActionListener listener)
	{
		myModel = m;
		m.addObserver(this);
		
		Character myCharacter = m.getPlayerCharacter();
		
		myNumBar = new NumberBar(myCharacter);
		myBottomMenu = new BottomMenu(myCharacter,listener);
		myIDPanel = IDPanel.initialize(myCharacter);
		
		myPanel = new JPanel();
	}

	public void setVisible(boolean b)
	{
		myPanel.setVisible(b);
	}

	public void close()
	{
		//TODO: what to put here?
		System.out.println("[VIEW] StatusViewport closed!");
	}

	protected Container getContainer()
	{
		return myPanel;
	}

	protected int getOffset()
	{
		return myNumBar.getOffset();
	}
	
	protected TakeableItem getSelectedInventoryItem()
	{
		//TODO: fill in once big menus are done
		return null;
	}
	
	protected EquippableItem getSelectedEquipmentItem()
	{
//		TODO: fill in once big menus are done
		return null;
	}
	
	protected Skill getSelectedSkill()
	{
//		TODO: fill in once big menus are done
		return null;
	}
	
	public void nextMode()
	{
		myNumBar.nextMode();
	}
	
	public void toggleMenu()
	{
		myBottomMenu.toggleMenu();
	}
	
	public void mupdate(Object o, Object param)
	{
		if (myModel == o)
		{
			myNumBar.setCharacter(myModel.getPlayerCharacter());
			myBottomMenu.setCharacter(myModel.getPlayerCharacter());
			myIDPanel.setCharacter(myModel.getPlayerCharacter());
		}
	}
	
	public void rotateBar()
	{
		myNumBar.rotate();
	}
	
	public void setMode(int barMode)
	{
		myNumBar.setMode(barMode);
	}
	
	public void setMenu(int i)
	{
		myBottomMenu.setMenu(i);
	}
	
	//accessors for number and status bars so they can be added to the frame directly
	
	public JPanel getNumBar()
	{
		return myNumBar;
	}
	
	public JPanel getBottomMenu()
	{
		return myBottomMenu;
	}
	
	public JPanel getIDPanel()
	{
		return myIDPanel;
	}
	
	/*public void setCharacter()
	{
		myNumBar.setCha
	}*/
	
	//showing/hiding the bigger menus
	
}

